import { DocFrameType, LcDocument, LcProject } from '../../types/editor.type';
import { ITypeEntity } from '../../../superType/types';
import { FileSystemEntry } from '../virtual-file-system/types';
import { IPublicTypeRootSchema } from '@alilc/lowcode-types';
import { UserEntity } from '../../../../modules/user/entities/user.entity';

export interface FileWriteResult {
  hash: string;
  isNewFile: boolean;
  isChanged: boolean;
  entry?: FileSystemEntry;
  doc?: Partial<LcDocument>;
  typeEntity?: Partial<ITypeEntity>;
  project?: Partial<LcProject>;
}

export interface ReadOptions {
  /* 目前用于前端除了返回代码还要实体资源 */
  returnSource?: boolean;
  currentFrame?: DocFrameType;
  typeEntity?: ITypeEntity;
  documentSchema?: IPublicTypeRootSchema;
}

export interface ReadResult {
  path: string;
  content: string;
  timestamp: number;
  entry?: FileSystemEntry;
  source?: any;
}

export interface WriteOptions {
  writeMode?: 'code' | 'vi';
  author?: string;
  message?: string;
  userId?: number;
  teamId?: number;
  user?: UserEntity;
  skipValidation?: boolean;
  documentSchema?: IPublicTypeRootSchema;
  /* 是否返回相关资源 */
  returnSource?: boolean;
  /* 仅预览，不存储 */
  preview?: boolean;
}